{
 "cells": [
  {
   "cell_type": "raw",
   "metadata": {
    "pycharm": {
     "name": "#%% raw\n"
    },
    "raw_mimetype": "text/restructuredtext"
   },
   "source": [
    ".. _nb_modact:"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "# MODAct\n",
    "\n",
    "MODAct (multi-objective design of actuators) is a real-world benchmark test-suite <cite data-cite=\"modact\"></cite> for constrained multi-objective optimization. The optimization problems aim at finding small electro-actuators given some objectives and constraints. Currently, there are 20 problems with up to 5 objectives and 10 inequaltiy constraints, summarized in the table below.\n",
    "\n",
    "In order to solve these problems, you will need to have the [modact](https://github.com/epfl-lamd/modact) package and its dependencies installed (Docker image available). A single solution evaluation takes about 20 ms. Therefore, the use of parallel schemes is advised. \n",
    "\n",
    "\n",
    "The estimated Pareto-fronts for CS1-4 and CT-4 have been added to pymoo directly. The others because of their file sizes have to be downloaded [here](https://doi.org/10.5281/zenodo.3824302), and used during initialization as shown below.\n",
    "\n",
    "For more information please refer to the associated publication <cite data-cite=\"modact\"></cite>.\n",
    "\n",
    "|Problem|Variables|Objectives|Constraints|\n",
    "|:---|:---|:---|:---|\n",
    "| CS1   | 20      |  2       | 7         |\n",
    "| CS2   | 20      |  2       | 8         |  \n",
    "| CS3   | 20      |  2       | 10        | \n",
    "| CS4   | 20      |  2       | 9         |\n",
    "| CT1, CTS1, CTSE1, CTSEI1  | 20  |  2,3,4 or 5  | 7  |  \n",
    "| CT2, CTS2, CTSE2, CTSEI2  | 20  |  2,3,4 or 5  | 8  |  \n",
    "| CT3, CTS3, CTSE3, CTSEI3  | 20  |  2,3,4 or 5  | 10 |  \n",
    "| CT4, CTS4, CTSE4, CTSEI4  | 20  |  2,3,4 or 5  | 9  |  \n",
    "\n",
    "Some usage examples are highlighted in the following sections."
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {
    "pycharm": {
     "name": "#%% raw\n"
    },
    "raw_mimetype": "text/restructuredtext"
   },
   "source": [
    ".. _nb_modact_cs3:"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "### CS3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "from pymoo.problems.multi import MODAct\n",
    "from pymoo.util.plotting import plot\n",
    "\n",
    "problem = MODAct(\"cs3\")\n",
    "plot(problem.pareto_front(), no_fill=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "### CT1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "from pymoo.util.plotting import plot\n",
    "\n",
    "problem = MODAct(\"ct1\")\n",
    "plot(problem.pareto_front(), no_fill=True)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "### CTS4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "pycharm": {
     "name": "#%%\n"
    }
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "\n",
    "from pymoo.problems.multi import MODAct\n",
    "from pymoo.visualization.scatter import Scatter\n",
    "\n",
    "pf = np.loadtxt(\"modact-cts3.pf\")\n",
    "\n",
    "problem = MODAct(\"cts4\", pf=pf)\n",
    "pf = problem.pareto_front()\n",
    "Scatter(angle=(45,45)).add(pf, color=\"red\").show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "pycharm": {
     "name": "#%% md\n"
    }
   },
   "source": [
    "<sub>Implementation by [the author (cyrilpic)](https://github.com/cyrilpic)."
   ]
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 4
}
